<template>
	<div class="card-buy-index">
		<details-focus></details-focus>
		<card-price></card-price>
		<card-service></card-service>
		<details-commodity-info></details-commodity-info>
		<card-btn></card-btn>
		
	</div>
</template>

<script>

	import detailsFocus from '../details/details-focus';
	import detailsCommodityInfo from '../details/details-commodity-info';
	import cardPrice from './card-price';
	import cardService from './card-service';
	import cardBtn from './card-btn';
	

	import Vue from 'vue';
	import VueResource from 'vue-resource';

	Vue.use(VueResource);
	Vue.http.options.emulateJSON = true;

	export default {
		data: function () {
			return {
				detailsFocusD: {} // focus data
				
			}
		},
		components: {
			detailsFocus,
			cardPrice,
			cardService,
			detailsCommodityInfo,
			cardBtn
		},
		ready: function () {

			var _this = this;

			this.$http.post('/api/detail/spuDetail.htm',{
				channelType: '1',
				spuCode: '105903'
			}).then(function ( d ) {
				var res = JSON.parse(d.data);
				var finallyDetailsFocusData = {};

				if ( res.result === 1 ) {

					finallyDetailsFocusData['spuName'] = res.obj.spuInfo.spuName;	
					finallyDetailsFocusData['androidImageList'] = res.obj.spuInfo.androidImageList;	

					// 写入data detailsFocus 组件	 
					for ( var i in finallyDetailsFocusData ) {
						Vue.set(_this.detailsFocusD, i, finallyDetailsFocusData[i] );
					}
					// 写入数据  chooseInfo 组件
					_this.detaileChooseInfo = res.obj.storeInfo;

					// 传送数据到	detailsFocus 组件
					_this.$broadcast('detailsFocusDataEvent', _this.detailsFocusD);
				};	

			}, function() {
				console.log('error');
			});
		}
	}

	
</script>

<style class="scss" scoped>
	
.details-index {
	font-family: "Microsoft YaHei";
}

</style>
